package com.wry.spring.extension;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * <h1> 全局异常处理 </h1>
 *
 * @author wry
 * @since 2025.04.06
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public String handleException(Exception e) {
        e.printStackTrace();
        if (e instanceof ArithmeticException) {
            return "数据异常";
        }
        return e.getMessage();
    }

}
